package edu.online.dal;

import edu.online.entity.LessonOrderEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface LessonOrderEntityMapper {
    @Delete({
        "delete from lessonorder",
        "where LessonOrderID = #{lessonorderid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String lessonorderid);

    @Insert({
        "insert into lessonorder (LessonOrderID, LessonID, ",
        "PayInfoID, StudentId, ",
        "AdminUserId, CreateTime, ",
        "OrderAmount)",
        "values (#{lessonorderid,jdbcType=CHAR}, #{lessonid,jdbcType=CHAR}, ",
        "#{payinfoid,jdbcType=CHAR}, #{studentid,jdbcType=CHAR}, ",
        "#{adminuserid,jdbcType=CHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{orderamount,jdbcType=INTEGER})"
    })
    int insert(LessonOrderEntity record);

    @InsertProvider(type=LessonOrderEntitySqlProvider.class, method="insertSelective")
    int insertSelective(LessonOrderEntity record);

    @Select({
        "select",
        "LessonOrderID, LessonID, PayInfoID, StudentId, AdminUserId, CreateTime, OrderAmount",
        "from lessonorder",
        "where LessonOrderID = #{lessonorderid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="LessonOrderID", property="lessonorderid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="LessonID", property="lessonid", jdbcType=JdbcType.CHAR),
        @Result(column="PayInfoID", property="payinfoid", jdbcType=JdbcType.CHAR),
        @Result(column="StudentId", property="studentid", jdbcType=JdbcType.CHAR),
        @Result(column="AdminUserId", property="adminuserid", jdbcType=JdbcType.CHAR),
        @Result(column="CreateTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="OrderAmount", property="orderamount", jdbcType=JdbcType.INTEGER)
    })
    LessonOrderEntity selectByPrimaryKey(String lessonorderid);

    @UpdateProvider(type=LessonOrderEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(LessonOrderEntity record);

    @Update({
        "update lessonorder",
        "set LessonID = #{lessonid,jdbcType=CHAR},",
          "PayInfoID = #{payinfoid,jdbcType=CHAR},",
          "StudentId = #{studentid,jdbcType=CHAR},",
          "AdminUserId = #{adminuserid,jdbcType=CHAR},",
          "CreateTime = #{createtime,jdbcType=TIMESTAMP},",
          "OrderAmount = #{orderamount,jdbcType=INTEGER}",
        "where LessonOrderID = #{lessonorderid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(LessonOrderEntity record);
}